package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.zr.gdms.service.CourseService;
import com.zr.gdms.serviceimpl.CourseServiceImpl;

/**
 * @author  shichongming
 * @E-mail: 
 * @date 创建时间：2017年6月1日 下午7:03:11 
 * @version 1.0 
 * @parameter  
 * @since  
 * @return  
 */

public class ShowAllCourseControllerSCM extends HttpServlet{
	
	CourseService cou=new CourseServiceImpl();
	//展示所有课题
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	// TODO Auto-generated method stub
	super.doGet(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
	req.setCharacterEncoding("UTF-8");
	resp.setCharacterEncoding("UTF-8");
	HttpSession session = req.getSession();
	int p=Integer.parseInt(req.getParameter("page"));
	int rows=Integer.parseInt(req.getParameter("rows"));
	int page=(p-1)*rows;
	int total= cou.sgetCountsCourse();
	JSONArray j=cou.showAllCourse(page, rows);
	JSONObject js=new JSONObject();
	js.put("total", total);
	js.put("rows", j);
	PrintWriter pw=resp.getWriter();
	pw.write(js.toString());
	}
}
